package com.texplose.controller;

import com.texplose.entity.vo.ResponseResult;
import com.texplose.service.CollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author : lyj
 * @Timer : 2022/5/23
 * @Description :
 */
@RestController
@RequestMapping("/collection")
public class CollectionController {
    @Autowired
    private CollectionService collectionService;


    @DeleteMapping("/{id}")
    public ResponseResult deleteCollectionById(@PathVariable("id") Integer id){
        collectionService.deleteCollectionById(id);
        return ResponseResult.okResult();
    }

    @DeleteMapping("/delete")
    public ResponseResult delete(Integer userId,Integer recipeId){
        return collectionService.delete(userId,recipeId);
    }

    @PutMapping("/addCollection")
    public ResponseResult addCollection(Integer userId,Integer recipeId){
        collectionService.addCollection(userId,recipeId);
        return ResponseResult.okResult();
    }

    @GetMapping("/countCollection/{id}")
    public ResponseResult countCollection(@PathVariable("id") Integer id){
        return collectionService.countCollection(id);
    }

    @GetMapping("/checkCollection")
    public ResponseResult checkCollection( Integer userId,Integer recipeId){
        return collectionService.checkCollection(userId,recipeId);
    }




}
